package anthology.daily_question._24_11;
//https://leetcode.cn/problems/find-the-count-of-numbers-which-are-not-special/description/?envType=daily-question&envId=2024-11-22
public class _323统计不是特殊数字的数字数量 {
    class Solution {
        public int nonSpecialCount(int l, int r) {
            int n = (int) Math.sqrt(r);
            int[] v = new int[n + 1];
            int res = r - l + 1;
            for (int i = 2; i <= n; i++) {
                if (v[i] == 0) {
                    if (i * i >= l && i * i <= r) {
                        res--;
                    }
                    for (int j = i * 2; j <= n; j += i) {
                        v[j] = 1;
                    }
                }
            }
            return res;
        }
    }
}
